//
//  BaseTableViewController.swift
//  ZTFWeibo
//
//  Created by Apple on 16/2/3.
//  Copyright © 2016年 ztf. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {

    var userLogin = false
    var visitorLoginView : VisitorLoginView?
    //loadView是苹果专门为手写代码准备的  等效与 sb / xib
    //一旦实现这个方法 xib/sb就自动失效
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorView()
        
    }
    
    private func loadVisitorView(){
        visitorLoginView = VisitorLoginView()
        //设置代理
        visitorLoginView?.visitorDelegate = self
        view = visitorLoginView
        
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLogin")
        
    }
    
    //MARK:visitorDelegate协议方法
    
    func visitorLogin() {
        print("登陆")
    }
    
    func visitorRegister() {
        print("注册")
    }
    
    
    override func viewDidLoad() {
       super.viewDidLoad()
        
        
    }
    
}
